python learning - the first python program helloworld

1, create a file called hello.py under the windows, and enter

. 1  Print ( ' hello world ' ) output hello world #

Then execute the command interpreter: python hello.py, output 

2, in the execution file hello.py method linux

Can be directly executed ./hello.py

PS: need to be given before execution of the execute permissions hello.py, chmod 755 hello.py (chmod command to add a permission, the authorization code representative of 755, on behalf of the user 7 (241-readable writable executable), 5 represents a belonging group (4 1-readable executable), 5 on behalf of other users (41-readable executable))

note:

If you need to perform in hello.py python interpreter, then you must specify the interpreter in hello.py file header, such as

1  # ! / Usr / bin / env environment variable to find Python on behalf of the entire system, it is recommended to use this. As long as the implementation of the interpreter, the head must add this line 
2 #! / Usr / bin / python This is equivalent to write the dead, and sought usr / under the bin, not recommended

 3, compare other languages

#include <iostream>
int main(void)
{
  std::cout<<"hello world!";  
}
C++
#include <stdio.h>
int main(void)
{
  printf("\nhello world!");
  return 0;  
}
C 
public class {the HelloWorld
  // entry program 
  public static void main (String args []) {
     // the console output 
   System.out.printIn ( " the Hello World! " );       
  }   
}
JAVA 
<?php
    echo "hello wrold!";
?>
PHP 
puts "hello world!"
RUBY
package main

import "fmt"

func main(){
 fmt.Printf("Hello World!\n God Bless You");
}
GO

 

Guess you like

Origin www.cnblogs.com/ommph/p/11362059.html