我試圖返回x的列表和閱讀與數字的文本文件,它例如後y座標元組:返回x的名單和y座標元組
68,125
113,69
65,86
108,149
152,53
我得在這裏我返回一個數字列表,但不是在一個元組中的對。
這裏是我的代碼:
def read_numbers(filename):
numbers = []
input_file = open(filename, "r")
content = input_file.readlines()
numbers = [word.strip() for word in content]
input_file.close()
return numbers
def main():
numbers = read_numbers('output.txt')
print(numbers)
main()
需要看起來像這樣:[(68,125),(113,69),(65,86),(108,149) ,(152,53)] –