1.%, which has several meanings?
Find a manual
Look at "The Python Libary Reference" section in Appendix index (P1899) python library guidelines:
% (percent):
datetime format, 198, 594, 596
environment variables expansion (Windows), 377, 1798
interpolation in configuration files, 493
operator, 31
printf-style formatting, 51, 65
According to the index usage by one index point of view:
- datetime format: represents the date format
- environment variables expansion environment variable expansion
- interpolation in configureation files insert settings file
- operator: Remainder
- printf-style formatting: Output Formatting
Environment variable expansion:
Expands environment variable placeholders %NAME% in strings like REG_EXPAND_SZ:
ExpandEnvironmentStrings('%windir%')
'C:\\Windows'
Insert settings file
home_dir: /Users
my_dir: %(home_dir)s/lumberjack
my_pictures: %(my_dir)s/Pictures
2. What is the meaning of ~?
Check the manual:
- ~ (tilde)
home directory expansion, 377
operator, 32
In addition to showing the outer home directory, it represents a bitwise operator (The bits of Inverted)
~ = -6. 5
~ -11 = 10
can be understood as a first 0 means positive number, taking the point of symmetry axis.
Resolve See: https://blog.csdn.net/oAlevel/article/details/79267644