c++ - setfill and setw python equivalent? -


i porting c++ code python didn't find out how translate this:

print  std::setfill('0') << std::setw(2) << std::hex << myvar << std::dec << " " 

how translate std::setfill('0') , std::setw(2) python?

there's no direct equivalent, can convert each value want display format function. see https://docs.python.org/2/library/string.html#format-specification-mini-language format specification.

print '{:02x}'.format(myvar) 

Comments

Popular posts from this blog

cgi - How do I interpret URLs without extension as files rather than missing directories in nginx? -

c++ - Visual Leak Detector detects leak on new blank MFC project -

c# - Connection String Trouble MetaDataException -