<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="fr">
	<id>https://knowledge.pinon-hebert.fr/mediawiki/index.php?action=history&amp;feed=atom&amp;title=Petits_exemples_de_code_Python</id>
	<title>Petits exemples de code Python - Historique des versions</title>
	<link rel="self" type="application/atom+xml" href="https://knowledge.pinon-hebert.fr/mediawiki/index.php?action=history&amp;feed=atom&amp;title=Petits_exemples_de_code_Python"/>
	<link rel="alternate" type="text/html" href="https://knowledge.pinon-hebert.fr/mediawiki/index.php?title=Petits_exemples_de_code_Python&amp;action=history"/>
	<updated>2026-05-19T11:56:09Z</updated>
	<subtitle>Historique des versions pour cette page sur le wiki</subtitle>
	<generator>MediaWiki 1.43.6</generator>
	<entry>
		<id>https://knowledge.pinon-hebert.fr/mediawiki/index.php?title=Petits_exemples_de_code_Python&amp;diff=1416&amp;oldid=prev</id>
		<title>Jpinon le 24 novembre 2025 à 09:12</title>
		<link rel="alternate" type="text/html" href="https://knowledge.pinon-hebert.fr/mediawiki/index.php?title=Petits_exemples_de_code_Python&amp;diff=1416&amp;oldid=prev"/>
		<updated>2025-11-24T09:12:37Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;a href=&quot;https://knowledge.pinon-hebert.fr/mediawiki/index.php?title=Petits_exemples_de_code_Python&amp;amp;diff=1416&amp;amp;oldid=1281&quot;&gt;Voir les modifications&lt;/a&gt;</summary>
		<author><name>Jpinon</name></author>
	</entry>
	<entry>
		<id>https://knowledge.pinon-hebert.fr/mediawiki/index.php?title=Petits_exemples_de_code_Python&amp;diff=1281&amp;oldid=prev</id>
		<title>Jpinon le 25 septembre 2025 à 08:49</title>
		<link rel="alternate" type="text/html" href="https://knowledge.pinon-hebert.fr/mediawiki/index.php?title=Petits_exemples_de_code_Python&amp;diff=1281&amp;oldid=prev"/>
		<updated>2025-09-25T08:49:13Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;fr&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Version précédente&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Version du 25 septembre 2025 à 08:49&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l51&quot;&gt;Ligne 51 :&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Ligne 51 :&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;Le script s&amp;#039;autoexplique. On utilise le module [[Python date et heure#Le module time|time]] el des [[ANSI|codes ansi]].&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;Le script s&amp;#039;autoexplique. On utilise le module [[Python date et heure#Le module time|time]] el des [[ANSI|codes ansi]].&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Fichier:Image-slock.png|sans_cadre|425x425px]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;L&#039;heure et la date s&#039;affiche au milieu de l&#039;écran avec le carret qui disparait. Si on tape une touche on remplace le texte jaune de la date par des espaces,le carret réapparait et le curseur revient là ou il était.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Si il y avait du texte sous la date comme c&#039;est le cas dans cet exemple il sera perdu et remplacé par des espaces.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key knowledge:diff:1.41:old-1279:rev-1281:php=table --&gt;
&lt;/table&gt;</summary>
		<author><name>Jpinon</name></author>
	</entry>
	<entry>
		<id>https://knowledge.pinon-hebert.fr/mediawiki/index.php?title=Petits_exemples_de_code_Python&amp;diff=1279&amp;oldid=prev</id>
		<title>Jpinon : Page créée avec « == Script pour éviter le delog automatique et afficher l&#039;heure == Souvent les connexions à la console ssh ont un time-out d&#039;inactivité très (trop) court.  Voici un petit programme python qui  affiche l&#039;heure au centre de l&#039;écran et attends l&#039;appuy sur une touche.&lt;syntaxhighlight lang=&quot;python3&quot;&gt; #!/bin/python3 import time import sys import select import termios import tty import shutil   # Obtenir la taille du terminal size = shutil.get_terminal_size() cols =... »</title>
		<link rel="alternate" type="text/html" href="https://knowledge.pinon-hebert.fr/mediawiki/index.php?title=Petits_exemples_de_code_Python&amp;diff=1279&amp;oldid=prev"/>
		<updated>2025-09-25T08:40:08Z</updated>

		<summary type="html">&lt;p&gt;Page créée avec « == Script pour éviter le delog automatique et afficher l&amp;#039;heure == Souvent les connexions à la console ssh ont un time-out d&amp;#039;inactivité très (trop) court.  Voici un petit programme python qui  affiche l&amp;#039;heure au centre de l&amp;#039;écran et attends l&amp;#039;appuy sur une touche.&amp;lt;syntaxhighlight lang=&amp;quot;python3&amp;quot;&amp;gt; #!/bin/python3 import time import sys import select import termios import tty import shutil   # Obtenir la taille du terminal size = shutil.get_terminal_size() cols =... »&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Nouvelle page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Script pour éviter le delog automatique et afficher l&amp;#039;heure ==&lt;br /&gt;
Souvent les connexions à la console ssh ont un time-out d&amp;#039;inactivité très (trop) court.&lt;br /&gt;
&lt;br /&gt;
Voici un petit programme python qui  affiche l&amp;#039;heure au centre de l&amp;#039;écran et attends l&amp;#039;appuy sur une touche.&amp;lt;syntaxhighlight lang=&amp;quot;python3&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/python3&lt;br /&gt;
import time&lt;br /&gt;
import sys&lt;br /&gt;
import select&lt;br /&gt;
import termios&lt;br /&gt;
import tty&lt;br /&gt;
import shutil&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Obtenir la taille du terminal&lt;br /&gt;
size = shutil.get_terminal_size()&lt;br /&gt;
cols = size.columns&lt;br /&gt;
rows = size.lines&lt;br /&gt;
&lt;br /&gt;
# FORMAT&lt;br /&gt;
date_format=&amp;quot;\u25C0 %Y-%m-%d %H:%M:%S \u25B6&amp;quot;;&lt;br /&gt;
# Calcul de la chaine&lt;br /&gt;
ssize=len(time.strftime(date_format))&lt;br /&gt;
&lt;br /&gt;
# Calculer la position centrale&lt;br /&gt;
center_x = (cols // 2)-(ssize//2)&lt;br /&gt;
center_y = rows // 2&lt;br /&gt;
&lt;br /&gt;
# Sauvegarder les paramètres du terminal&lt;br /&gt;
fd = sys.stdin.fileno()&lt;br /&gt;
old_settings = termios.tcgetattr(fd)&lt;br /&gt;
tty.setcbreak(fd)  # Mode caractère par caractère&lt;br /&gt;
print (&amp;quot;Sleep mode. Type any key to resume...&amp;quot;)&lt;br /&gt;
print (&amp;quot;\033[?25l\033[s&amp;quot;,end=&amp;quot;&amp;quot;) # on desactive l&amp;#039;affichage du &amp;quot;carret&amp;quot; du curseur et on sauve sa position&lt;br /&gt;
try:&lt;br /&gt;
    print (&amp;quot;\033[?25l\033[s&amp;quot;,end=&amp;quot;&amp;quot;)&lt;br /&gt;
    while True:&lt;br /&gt;
        if select.select([sys.stdin], [], [], 0)[0]: # Si une touche est pressée&lt;br /&gt;
            break # on sort du &amp;#039;while&amp;#039;&lt;br /&gt;
        print(f&amp;quot;\033[{center_y};{center_x}H&amp;quot;, end=&amp;quot;&amp;quot;)&lt;br /&gt;
        now = time.time()&lt;br /&gt;
        ts=time.localtime(now)&lt;br /&gt;
        f=time.strftime(&amp;quot;\033[103m\033[31m&amp;quot;+date_format+&amp;quot;\033[0m&amp;quot;,ts)&lt;br /&gt;
        print (f,end=&amp;quot;&amp;quot;,flush=True)&lt;br /&gt;
        time.sleep(0.1)&lt;br /&gt;
finally:&lt;br /&gt;
    termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)  # Restaurer terminal&lt;br /&gt;
    print(f&amp;quot;\033[{center_y};{center_x}H&amp;quot;+&amp;quot; &amp;quot;*ssize, end=&amp;quot;&amp;quot;) # On se positionne au centre&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;\033[u\033[?25h&amp;quot;, end=&amp;quot;&amp;quot;)  # Restaurer position curseur et on affiche le carret&lt;br /&gt;
    print(&amp;quot;Sleep mode terminated&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;Le script s&amp;#039;autoexplique. On utilise le module [[Python date et heure#Le module time|time]] el des [[ANSI|codes ansi]].&lt;/div&gt;</summary>
		<author><name>Jpinon</name></author>
	</entry>
</feed>