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
Post a Comment