Suggest that I have this:
valuestringdate = "24/6/2010"
and I want to get something like this from the variable
day = 24
month = 6
year = 2010
您可以split
字符串:
day, month, year = valuestringdate.split('/')
Use the .split() method. In this case, dateList = valuestringdate.split("/")
Which would produce list: dateList = ["24","6","2010]
Using indexes: day = dateList[0]
would set day = "24"
From there you can use day = int(day)
to convert the day from a string to an integer.
You should be able to figure it out from there.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.