Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am aware that you can use the pwd module on python to extract passwd structures for use; however, my question is as such:
if I read into my program a line such as
blah1:tVNIsQ0yDrLxM:16009:0:99999:7:::
or
blah2:$6$WVsjYh8e$5r2wvIaeiFI6CCFRw6stfbah0Q.wrcKITdmEDCvG2cNC4fXkVbgRiOdeCdU.WeD1NIyzLh/sXycXQFEQcNWsv/:16009:0:99999:7:::
how would I read just the section that reads "tVNIsQ0yDrLxM"?
Thank you
As long as there's no extra colons in there, this should work:
password = hash.split(':')[1]
split
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
As a better definition, how to write the following function in Python ?
def create_shortcut(source, dest):
create a shortcut of file 'source' and put it in 'dest'
If by "shortcut" you mean symlink, it's just
import os
os.symlink(source,dest)
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am trying to write a function that loops through a .txt file of a books and identifies chapters. I am using the appearance of more than one \n in a row followed by one line of non \n text to signify a new chapter. How would you guys structure the loops to do this? I personally am using python, but you should feel free to keep your answers as abstract as possible.
chapters = filter(None,map(str.strip,text.split("\n\n")))
you could also do it with re using Stevens answer from the comments
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
Just started python and need to do binary to denary (vice versa) but get invalid syntax for int(.
That's weird, this works fine:
int('0b10101010', 2)
=> 170
And so does this:
bin(170)
=> '0b10101010'
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Just wondering how can you send JSON data to the front end of a web app using Flask. Don't have that much experience with it, just looking for some ideas?
Create a dictionary Dict.
If Dict is your dictionary, you can just do
return flask.jsonify(**Dict)
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 8 years ago.
Improve this question
I have a set of html files, I need to translate their content. On the way out to get the same set of html but translated.
All this is handled locally.
Parse them with BeautifulSoup, get the strings in the markup, and then use the Rest API provided by Google to translate them. Put them back in your html files using BeautifulSoup one more time.
This is just the general algorithm, look at the two documentation, and come back if you have any more questions