#Python TQC考題909
f_name = “data.dat”
file = open(f_name,”wb”)
# TODO
for i in range(5):
inp = input()
b_inp = bytearray(inp+”\n”,”utf-8″)
file.write(b_inp)
file.close()
print(‘The content of “data.dat”:’)
with open(f_name,”rb”) as file:
for line in file:
print(line.decode(“utf-8”))
“””
The content of “data.dat”:
“””

#只要加encoding=”utf-8″
#b模式都用不到,如: rb, wb




![Python常用的模組內建常數; __name__ ; __file__ ; __doc__ ; __all__ ;__dict__; vars()->Dict[str,str] ; dir()->List[str] Python常用的模組內建常數; __name__ ; __file__ ; __doc__ ; __all__ ;__dict__; vars()->Dict[str,str] ; dir()->List[str]](https://i2.wp.com/savingking.com.tw/wp-content/uploads/2022/11/20221112184006_50.png?quality=90&zoom=2&ssl=1&resize=350%2C233)


![Python: 如何使用 os.environ[“PATH”] 設定環境變數?與 sys.path.append() 差別為何? Python: 如何使用 os.environ[“PATH”] 設定環境變數?與 sys.path.append() 差別為何?](https://i0.wp.com/savingking.com.tw/wp-content/uploads/2024/09/20240905135312_0_890fa1.png?quality=90&zoom=2&ssl=1&resize=350%2C233)



近期留言