area.ini內容:
[numbers]
pi: 3.1415926535897931
[message]
greeting: Welcome to the area calculation program!
question: Please enter the radius:
result_message: The area is
代碼:
from configparser import ConfigParser
if __name__ == '__main__':
CONFIGFILE = 'area.ini'
config = ConfigParser
config.read(CONFIGFILE)
print(config['messages'].get('greeting'))
radius = float(input(config['message'].get('question') + ''))
print(config['message'].get('result_message'), end=' ')
print(config['message'].getfloat('pi') * radius**2)
報錯:
config.read(CONFIGFILE)這行代碼報錯,報錯內容為
TypeError: read() missing 1 required positional argument: 'filenames'
麻煩各各位大佬指點一下,謝謝
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/242047.html
上一篇:用cxfreeze轉換exe檔案時出現missing modules錯誤應該怎么處理求大神解惑?
下一篇:pygame定時器問題
