[英]pygame.mouse.get_pos() into two separate strings
I'm using pygame and am using the code pygame.mouse.get_pos() , but need to turn this into two seperate strings: one where x = the x coordinate, and one where y = the y coordinate. 我正在使用pygame,并且正在使用代码pygame.mouse.get_pos() ,但是需要将其转换为两个单独的字符串:一个其中x = x坐标,另一个其中y = y坐标。 Thanks for the help. 谢谢您的帮助。
pygame.mouse.get_pos()
returns a tuple of two integers, x positions and y position: pygame.mouse.get_pos()
返回两个整数的元组,x位置和y位置:
>>> pygame.mouse.get_pos()
(413, 129)
You just need to creat two new strings based on these two values: 您只需要基于这两个值创建两个新的字符串:
xpos_str = str(pygame.mouse.get_pos()[0])
ypos_str = str(pygame.mouse.get_pos()[1])
您可以使用地图:
x, y = map(str, pygame.mouse.get_pos())
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.