[問題] input輸入問題,已解決

看板Python作者時間7年前 (2018/08/15 20:24), 7年前編輯推噓2(2012)
留言14則, 6人參與, 7年前最新討論串1/1
如題,我想在原input輸入股票名稱然後希望pandas幫我去爬蟲網頁 import pandas as pd stock_name =input('請輸入股名:') df = pd.read_html('http;//******.com.tw) #年報2015-2017年 其中****(能夠隨input輸入而更改),******部分我希望能是input輸入的東西, 但是礙於pd.read_html('')內必須是字串方式呈現。 想了幾天都沒想出要怎麼解決? 請教版友 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 114.39.217.77 ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1534335882.A.748.html

08/15 20:29, 7年前 , 1F
format?
08/15 20:29, 1F

08/15 23:23, 7年前 , 2F

08/15 23:39, 7年前 , 3F
樓上的0可以省略 Python很聰明會幫你算
08/15 23:39, 3F

08/16 00:32, 7年前 , 4F
08/16 00:32, 4F

08/16 12:51, 7年前 , 5F
查一下 string format 用法
08/16 12:51, 5F
※ 編輯: wii8898333 (39.9.227.162), 08/17/2018 04:13:46

08/17 08:29, 7年前 , 6F
二樓就給你答案了 可見你有看沒有懂...
08/17 08:29, 6F

08/17 08:30, 7年前 , 7F
用 format 已經幫你自動轉型了 根本不存在你的字串形式
08/17 08:30, 7F

08/17 08:31, 7年前 , 8F
format 會呼叫帶入引數的 __str__ () 就轉惹拉...
08/17 08:31, 8F

08/17 14:41, 7年前 , 9F
感謝s大的教導,已經順利解決問題並學到一個用法了
08/17 14:41, 9F

08/17 19:54, 7年前 , 10F
從這頁往下翻 3 頁 https://goo.gl/iRCYkU
08/17 19:54, 10F

08/17 19:54, 7年前 , 11F
都是介紹 format
08/17 19:54, 11F

08/17 19:55, 7年前 , 12F
.format(**locals()) 應該是寫熟後最常寫的方法
08/17 19:55, 12F

08/18 02:59, 7年前 , 13F
謝謝s大陸續提供知識來源,版上真的解決好多疑問。謝
08/18 02:59, 13F

08/18 02:59, 7年前 , 14F
謝大家
08/18 02:59, 14F
文章代碼(AID): #1RT1kAT8 (Python)
文章代碼(AID): #1RT1kAT8 (Python)