huang 0 like s 464 view s
Tags:
https://chat.openai.com/chat
write a script, output the first token of every line of a file
```
with open("file.txt", "r") as file: # Loop through each line in the file for line in file: # Strip the line to remove any leading or trailing whitespace line = line.strip() # Split the line into tokens (words) tokens = line.split() # Print the first token (word) print(tokens[0]) ```
点赞本文的读者
还没有人对此文章表态
没有评论
Sorry, 没有相似文章
© 2023 XGenes.com Impressum